<?php
/**
 * FileName: system.php
 * Author: Fei.Song
 * Date: 2021/5/12 15:03
 * Created by PhpStorm
 * Desc: 平台管理路由文件
 */

use Illuminate\Support\Facades\Route;

Route::get('system/change', [\App\Http\Controllers\Admin\LoginController::class, 'changeShow'])->middleware('adminlogin')->name('system.changeShow');
Route::post('system/change/{id}', [\App\Http\Controllers\Admin\LoginController::class, 'change'])->middleware('adminlogin')->name('system.change');

//平台
Route::name('system.')->prefix('system')->middleware(["auth:system", "adminlogin", "admininit","routes"])->namespace("\App\Http\Controllers\System")->group(function () {
    //平台管理首页
    Route::name('index')->get('/', "IndexController@index");

    //平台管理-站点管理
    Route::name('site.')->prefix('site')->group(function () {
        Route::name('index')->get('index', "SiteController@index");
        Route::name('create')->get('create', "SiteController@create");
        Route::name('store')->post('store', "SiteController@store")->withoutMiddleware(["routes"]);//权限规则待定;
        Route::name('show')->get('show/{id}', "SiteController@show");
        Route::name('edit')->get('edit/{id}', "SiteController@edit");
        Route::name('update')->post('update/{id}', "SiteController@update")->withoutMiddleware(["routes"]);//权限规则待定;
    });

});

//平台
Route::name('system.')->prefix('system')->middleware(["auth:system", "adminlogin", "admininit"])->namespace("\App\Http\Controllers\Admin")->group(function () {
    //用户相关路由
    Route::name('user.')->prefix('user')->group(function () {
        Route::name('index')->get('index', 'UserController@index');
        Route::name('create')->match(["get","post"],'create', 'UserController@create');
        Route::name('edit')->get('edit/{user}', 'UserController@edit');
        Route::name('update')->post('update/{id}', 'UserController@update')->withoutMiddleware(["routes"]);//权限规则待定
        Route::name('destroy')->get('destroy/{id}', 'UserController@destroy');//没有删除
        Route::name('search')->get('search/{key}', 'UserController@search')->withoutMiddleware(["routes"]);//权限规则待定
        Route::name('upload')->post('upload', 'UserController@upload')->withoutMiddleware(["routes"]);//权限规则待定
        Route::name('show')->get('show/{user}', 'UserController@show');
        Route::name('onoff')->get('onoff', 'UserController@isOpen');
        Route::name('role_form')->get('role_form/{user}', 'UserController@role_form');
        Route::name('role_assign')->post('assign/{user}', 'UserController@assign')->withoutMiddleware(["routes"]);//权限规则待定
        Route::name('change_pwd')->get('change_pwd/{user_id}', 'UserController@changePwdShow');
        Route::name('change_store')->post('change/{id}', 'UserController@changePwd')->withoutMiddleware(["routes"]);//权限规则待定
    });

    //权限相关路由
    Route::name('permission.')->prefix('permission')->group(function () {
        Route::name('index')->get('index', "PermissionController@index");
        Route::name('create')->get('create', "PermissionController@create");
        Route::name('store')->post('store', "PermissionController@store")->withoutMiddleware(["routes"]);//权限规则待定
        Route::name('show')->get('show/{permission}', "PermissionController@show");
        Route::name('edit')->get('edit/{id}', "PermissionController@edit");
        Route::name('update')->post('update/{id}', "PermissionController@update")->withoutMiddleware(["routes"]);//权限规则待定
        Route::name('status')->get('status', "PermissionController@status");
        Route::name('check')->get('check', "PermissionController@check_route")->withoutMiddleware(["routes"]);//权限规则待定
        Route::name('select')->get('select', "PermissionController@getSelect")->withoutMiddleware(["routes"]);//权限规则待定
    });

    //菜单相关
    Route::name('menu.')->prefix('menu')->group(function () {
        Route::name('index')->get('index', "MenuController@index");
        Route::name('create')->get('create', "MenuController@create");
        Route::name('store')->post('store', "MenuController@store")->withoutMiddleware(["routes"]);//权限规则待定
        Route::name('edit')->get('edit/{id}', "MenuController@edit");
        Route::name('update')->post('update/{id}', "MenuController@update")->withoutMiddleware(["routes"]);//权限规则待定
        Route::name('destroy')->get('destroy/{id}', "MenuController@destroy");//不需要删除
        Route::name('check')->get('check', "MenuController@check_route")->withoutMiddleware(["routes"]);//权限规则待定
        Route::name('edit.attach.1')->get('sort/{id}/{sort}', "MenuController@setSort");

    });

    //角色相关
    Route::name('role.')->prefix('role')->group(function () {
        Route::name('index')->get('index', 'RoleController@index');
        Route::name('create')->get('create', 'RoleController@create');
        Route::name('store')->post('store', 'RoleController@store')->withoutMiddleware(["routes"]);//权限规则待定
        Route::name('show')->get('show/{role}', 'RoleController@show');
        Route::name('edit')->get('edit/{id}', 'RoleController@edit');
        Route::name('update')->post('update/{id}', 'RoleController@update')->withoutMiddleware(["routes"]);//权限规则待定
        Route::name('destroy')->get('destroy/{id}', 'RoleController@destroy');
        Route::name('per_form')->get('assign_form/{id}', 'RoleController@per_form');
        Route::name('permission_assign')->post('assign/{role_id}', 'RoleController@assign')->withoutMiddleware(["routes"]);//权限规则待定
    });

    //部门管理相关
    Route::name('org.')->prefix('org')->group(function () {
        Route::name('index')->get('index', "OrgController@index");
        Route::name('show')->get('show/{org}', "OrgController@show");
        Route::name('create')->get('create', "OrgController@create");
        Route::name('store')->post('store', "OrgController@store")->withoutMiddleware(["routes"]);//权限规则待定
        Route::name('edit')->get('edit/{org}', "OrgController@edit");
        Route::name('update')->post('update/{id}', "OrgController@update")->withoutMiddleware(["routes"]);//权限规则待定
        Route::name('select')->get('select', "OrgController@select")->withoutMiddleware(["routes"]);//权限规则待定
        Route::name('index.attach.1')->get('sort/{id}/{sort}', "OrgController@setSort");
    });
});
